#include "dialog.h"
#include "ui_dialog.h"

#include <QFileDialog>
#include<QFileInfo>
Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::Dialog)
{
    this->setMinimumSize(100,48);
    ui->setupUi(this);
    lb1=new QLabel(this);
    lb2=new QLabel(this);
    lb1->setText("文件名称");
    lb2->setText("文件大小");
    bt1=new QPushButton(this);
    bt2=new QPushButton(this);
    bt1->setText("选择...");
    bt2->setText("获取文件大小信息");
    le1=new QLineEdit(this);
    le2=new QLineEdit(this);
    layout=new QGridLayout(this);
    layout->addWidget(lb1,0,0);
    layout->addWidget(le1,0,1);
    layout->addWidget(bt1,0,2);
    layout->addWidget(lb2,1,0);
    layout->addWidget(le2,1,1,1,2);
    layout->addWidget(bt2,2,0,1,3);

    connect(bt1,&QPushButton::clicked,this,&Dialog::selectFile);
    connect(bt2,&QPushButton::clicked,this,&Dialog::getFileSize);

}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::selectFile()
{
    QString path=QFileDialog::getOpenFileName(this,"打开","/","FIles(*)");
    le1->setText(path);
}

void Dialog::getFileSize()
{
    QFileInfo info(le1->text());
    qint64 FileSize=info.size();
    le2->setText(QString::number(FileSize));


}



